using System;

namespace ActiveSupport.Time
{
    public static class IntegerTimeExtensions
    {
        public static TimeSpan Seconds(this int source)
        {
            return TimeSpan.FromSeconds(source);
        }

        public static TimeSpan Minutes(this int source)
        {
            return TimeSpan.FromMinutes(source);
        }

        public static TimeSpan Hours(this int source)
        {
            return TimeSpan.FromHours(source);
        }

        public static TimeSpan Days(this int source)
        {
            return TimeSpan.FromDays(source);
        }

        public static TimeSpan Weeks(this int source)
        {
            return TimeSpan.FromDays(7 * source);
        }

        public static DateTime Ago(this TimeSpan source)
        {
            return Until(source, DateTime.Now);
        }

        public static DateTime FromNow(this TimeSpan source)
        {
            return Since(source, DateTime.Now);
        }

        public static DateTime Until(this TimeSpan source, DateTime targetDate)
        {
            return targetDate.Subtract(source);
        }

        public static DateTime Since(this TimeSpan source, DateTime targetDate)
        {
            return targetDate.Add(source);
        }
    }
}